<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html lang="en">
	<head>
		<title>工作时间</title>
	    <%@include file="/common/commonCSS.jsp" %>
	    <%@include file="/common/commonJS.jsp" %>
		<%@ include file="/WEB-INF/jsp/include/taglib.jsp"%>
	</head>
	<body >
		<div class="main-container" id="main-container">
			<form class="form-horizontal  bv-form" id="incidentForm">
				<div style="display: none">
					<input id="id" name="id"  value="${timetblWorkdate.id}"/>
				</div>
				<div class="row">
					<div class="form-group col-xs-12 ">
						<label class="col-xs-3 control-label no-padding-right"><i class="red"> * </i>开始时间:</label>
						<div class="col-xs-9">
							<span class="col-xs-11 block input-icon input-icon-right">
								<input id="beginDate" name="beginDate" type="text" class="form-control" value="<fmt:formatDate value="${timetblWorkdate.beginDate}" pattern="yyyy-MM-dd HH:mm:ss"/>" />
							</span>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="form-group col-xs-12 ">
						<label class="col-xs-3 control-label no-padding-right">结束时间:</label>
						<div class="col-xs-9">
							<span class="col-xs-11 block input-icon input-icon-right">
								<input id="endDate" name="endDate"  type="text" class="form-control" value="<fmt:formatDate value="${timetblWorkdate.endDate}" pattern="yyyy-MM-dd HH:mm:ss"/>"/>
							</span>
						</div>
					</div>
				</div>

				<div class="row">
					<div class="form-group col-xs-12">
						<label class="col-xs-3 control-label no-padding-right"><i class="red"> * </i> 是否节假日:</label>
						<div class="col-xs-9">
							<span class="col-xs-11 block input-icon input-icon-right">
								<tag:select nameKey="workDateType" name="workDateType" clazz="form-control" otherAttr="datatype=\"*\" " isAddDefaltOption="true" defaltOptionValue="--请选择--" initSelectedKey="${timetblWorkdate.workDateType}"/>

							</span>
						</div>
					</div>
				</div>



				<div class="row" style="margin-left: 40%;padding-bottom: 28px;margin-top: 25px;">
					<button class="layui-btn" type="button" id="submitBtn">保 存</button>
					<%--<a class="layui-btn layui-btn-normal" href="${webRoot}/sys/timetblworkdate/list">返 回</a>--%>
				</div>
			</form>
		</div>
	</body>
	<script>
		//提交
		$("#submitBtn").click(function () {
            checkFormValid($("#incidentForm"),function () {
			var url ="${webRoot}/sys/timetblworkdate/save";
			$.post(url,$("#incidentForm").serialize(),function (result) {
				if(result.code == '0'){
					if($("#id").val() == ''){
                        alert(result,function () {
                            workdateList(result);
                            //parent.location.reload();
                            closeThisWindow();
                            //location.href='${webRoot}/sys/timetblworkdate/list';
                        },function () {
                            $("#submitBtn").reset();
                        });
					}else {
                        //更新成功，返回List页面
                        toast(result.msg);
                        workdateList(result);
                        //parent.location.reload();
                        //关闭弹框
                        closeThisWindow();
                        //location.href='${webRoot}/sys/timetblworkdate/list';
					}
				}else {
					alertMsg(result.msg);
				}

			});
		})
		});

        function workdateList(result) {
            var userTab=$(parent.document.getElementById("tabContent1")).find("#table-list tbody");
            var index=userTab.find("tr").length;
            var html ="";

            userTab.find("tr").each(function () {
                var trid = $(this).attr("id");
                if(trid ==result.timetblWorkdate.id){
                    $(this).remove();
                }
            })

            html+="<tr id='"+result.timetblWorkdate.id+"'>";
            html+=" <td style='display: none'>";
            html+="  	<input name='timetblWorkdateIds' value='"+result.timetblWorkdate.id+"'/>";
            html+="  </td>";
            html+=" <td>"+result.beginDate+"</td>";
            html+=" <td>"+result.endDate+"</td>";
            html+=" <td>"+result.workDateType+"</td>";
            html+="<td> <div class=\" btn-group \"> " +
                "<button class=\"layui-btn layui-btn-danger layui-btn-small\" type=\"button\" onclick=\"addInfo('"+result.timetblWorkdate.id+"')\"><i class=\"layui-icon\">&#xe642;</i> 编辑</button>";
            html+="<button class='layui-btn layui-btn-danger layui-btn-small' type='button' onclick=\"deleteById('"+result.timetblWorkdate.id+"')\"><i class='layui-icon'>&#xe640;</i>删除</button>";
			html+="</div>  </td> </tr>";
            userTab.append(html);
        }

        laydate.render({
            elem: '#beginDate' //指定元素
            ,type: 'datetime'
        });
        laydate.render({
            elem: '#endDate' //指定元素
            ,type: 'datetime'
        });
	</script>
</html>